package com.sakila.action.actor;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sakila.action.BaseAction;
import com.sakila.pojo.Actor;
import com.sakila.pojo.other.Page;
import com.sakila.service.ActorService;

@Controller
public class ActorAction implements BaseAction{
	
	private ActorService actorService;

	@Autowired
	public void setActorService(ActorService actorService) {
		this.actorService = actorService;
	}
	
/*	@RequestMapping(value="/viewActor", method=RequestMethod.GET)
	public String viewList(Model model){
		List<Actor> list = actorService.selectAll(new Page(1, 30));
		model.addAttribute("list", list);
		return "actor/actor";
	}*/
	
	@RequestMapping(value="/viewActor")
	@ResponseBody
	public List<Actor> viewList(
			@RequestParam(value=PAGE_ID,defaultValue="1")int pageId,
			@RequestParam(value=PAGE_SIZE,defaultValue="30")int pageSize){
		List<Actor> list = actorService.findAll(new Page(pageId, pageSize));
		return list;
	}
}
